package com.eureka.server;

import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRenewedEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaRegistryAvailableEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaServerStartedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;


//@Component
public class EurekaStateChangeListener {

	@EventListener
	public void listen(EurekaInstanceCanceledEvent eurekaInstanceCanceledEvent) {
		// 服务断线事件
//		String appName = eurekaInstanceCanceledEvent.getAppName();
//		String serverId = eurekaInstanceCanceledEvent.getServerId();
//		System.out.println("cancel appName: "+ appName);
//		System.out.println("cancel serverId: " +serverId);
	}

	@EventListener
	public void listen(EurekaInstanceRegisteredEvent event) {
		//InstanceInfo instanceInfo = event.getInstanceInfo();
//		System.out.println("register instanceInfo: "+ instanceInfo);
	}

	@EventListener
	public void listen(EurekaInstanceRenewedEvent event) {
//		System.out.println("eureka server renewed : "+event.getAppName());
//		System.out.println("eureka server renewed : "+event.getServerId());
	}

	@EventListener
	public void listen(EurekaRegistryAvailableEvent event) {
	}

	@EventListener
	public void listen(EurekaServerStartedEvent event) {
		// Server启动
//		System.out.println("eureka server start....");
	}
}
